package com.realtyManage.springboot.Controller;

import com.alibaba.fastjson.JSON;
import com.realtyManage.springboot.Config.AliMessage;
import com.realtyManage.springboot.Config.WxProgramPayConfig;
import com.realtyManage.springboot.Model.Do.*;
import com.realtyManage.springboot.Model.Vo.BaseEntity;
import com.realtyManage.springboot.Model.Vo.RegEntity;
import com.realtyManage.springboot.Service.*;
import com.realtyManage.springboot.Service.impl.DictionariesServiceImpl;
import com.realtyManage.springboot.Service.impl.HouseFansServiceImpl;
import com.realtyManage.springboot.Utils.BuildTreeUtil;
import com.realtyManage.springboot.Utils.RedisService;
import com.realtyManage.springboot.Utils.SysExecRsUtil;
import com.realtyManage.springboot.wxpay.PayUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * ExternalConnectionController
 *
 * @Author 杭州素色网络科技有限公司
 * @Date 2019/9/25
 * 外接信息
 **/

@Controller
@RequestMapping("/")
public class ExternalConnectionController {

    @Autowired
    private HouseFansServiceImpl houseFansServiceImp;

    /**
     * 插入平台导入量
     * @param request
     */
    @RequestMapping(value = "/insertImportNum",method = RequestMethod.POST)
    private void insertImportNum(HttpServletRequest request) {
        houseFansServiceImp.insertImportNum();
    }

    /**
     * 插入平台分销量
     * @param request
     */
    @RequestMapping(value = "/insertDistributionNum",method = RequestMethod.POST)
    private void insertDistributionNum(HttpServletRequest request) {
        houseFansServiceImp.insertDistributionNum();
    }

    /**
     * 插入平台带客量
     * @param request
     */
    @RequestMapping(value = "/insertBeltCustomerNum",method = RequestMethod.POST)
    private void insertBeltCustomerNum(HttpServletRequest request) {
        houseFansServiceImp.insertBeltCustomerNum();
    }

    /**
     * 插入平台成交量
     * @param request
     */
    @RequestMapping(value = "/insertDealNum",method = RequestMethod.POST)
    private void insertDealNum(HttpServletRequest request) {
        houseFansServiceImp.insertDealNum();
    }

    /**
     * 获取平台外接信息
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getExternalConnectionList",method = RequestMethod.GET)
    private String getExternalConnection(HttpServletRequest request){
        List<ExternalConnection> list  = houseFansServiceImp.getExternalConnectionList();
        return  JSON.toJSONString(list);
    }

    /**
     * 群发送短信
     * @param request
     * @return
     */
    @RequestMapping(value = "/setSMS",method = RequestMethod.GET)
    private String setSMS(HttpServletRequest request) {
        String phones = request.getParameter("phones");
        String[] phone = phones.split(",");
        for (String telephone : phone){
            AliMessage.sendMessage(6, "",telephone);
        }
        RegEntity regInfo = new RegEntity();
        regInfo.setInfoCode(1);
        regInfo.setInfoText(SysExecRsUtil.getMsgFromCode(1));
        return JSON.toJSONString(regInfo);
    }


}
